package com.sky.mapper.user;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository("userShoppingCart")
public interface ShoppingCartMapper {

//    @Select("SELECT *from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> select(ShoppingCart shoppingCart);


    @Insert("insert into shopping_cart (id, name, image, user_id, dish_id, setmeal_id, dish_flavor, number, amount, create_time) " +
            "values (#{id}, #{name}, #{image}, #{userId}, #{dishId}, #{setmealId}, #{dishFlavor}, #{number}, #{amount}, #{createTime})")
    void insert(ShoppingCart shoppingCart);




    @Update("update shopping_cart set number = #{number} where user_id = #{userId} and id = #{id}")
    void update(ShoppingCart shoppingCart);

    @Delete("delete from shopping_cart where user_id = #{currentId};")
    void deleteAll(Long currentId);


    @Delete("delete from shopping_cart where id = #{id};")
    void deleteById(ShoppingCart shoppingCart);
}
